function n() {
    return new Promise(function(n, e) {
        wx.getStorageSync(r.loginToken) ? n(wx.getStorageSync(r.loginToken)) : wx.login({
            success: function(e) {
                e.code ? o.get(r.login, {
                    code: e.code
                }).then(function(e) {
                    if (0 == e.status) try {
                        wx.setStorageSync(r.loginToken, e.data.loginToken), n(e.data.loginToken);
                    } catch (n) {}
                }) : wx.showToast({
                    title: "网络错误！",
                    icon: "none",
                    duration: 1e3
                });
            }
        });
    });
}

var e = require("942C1195C63E4BDFF24A79927AF97135.js"), t = require("04492143C63E4BDF622F494414C97135.js"), o = require("7512B3B0C63E4BDF1374DBB7D42A7135.js"), r = require("14D6B083C63E4BDF72B0D88468E97135.js"), i = function(n) {
    return (n = n.toString())[1] ? n : "0" + n;
};

module.exports = {
    formatTime: function(n) {
        var e = n.getFullYear(), t = n.getMonth() + 1, o = n.getDate(), r = n.getHours(), c = n.getMinutes(), a = n.getSeconds();
        return [ e, t, o ].map(i).join("/") + " " + [ r, c, a ].map(i).join(":");
    },
    isLogin: function() {
        try {
            return !!wx.getStorageSync("loginOpenid");
        } catch (n) {}
    },
    getOpenid: function() {
        try {
            return wx.getStorageSync("loginOpenid");
        } catch (n) {}
    },
    setLoginOpenid: function(n) {
        try {
            wx.setStorageSync("loginOpenid", n);
        } catch (n) {}
    },
    jumpLogin: function(n) {
        wx.navigateTo({
            url: "/pages/login/login?returnUrl=" + encodeURIComponent(n)
        });
    },
    jumpMinProgram: function(n, e) {
        wx.navigateToMiniProgram({
            appId: n,
            path: e,
            extraData: {},
            envVersion: "",
            success: function(n) {},
            fail: function(n) {}
        });
    },
    parseLikeNum: function(n) {
        return n < 1e3 ? n : n >= 1e3 && n < 1e4 ? (n / 1e3).toFixed(1) + "K" : (n / 1e4).toFixed(1) + "W";
    },
    wxLog: function(n) {
        n && (void 0 == (n = JSON.parse(n)).key && (n.key = {}), e.Event.stat(n.event, n.key));
    },
    encrypt: function(n) {
        var e = t.enc.Utf8.parse("Wm3WZYTPz0wzccnW");
        return t.AES.encrypt(n, e, {
            mode: t.mode.ECB,
            padding: t.pad.Pkcs7
        });
    },
    decrypt: function(n) {
        var e = t.enc.Utf8.parse("Wm3WZYTPz0wzccnW");
        return t.AES.decrypt(n, e, {
            mode: t.mode.ECB,
            padding: t.pad.Pkcs7
        }).toString(t.enc.Utf8);
    },
    login: n,
    getUser: function() {
        wx.getUserInfo({
            success: function(e) {
                console.log(e);
                var t = e.userInfo;
                console.log(t);
                var i = {
                    user_name: t.nickName,
                    user_face: t.avatarUrl,
                    gender: t.gender
                };
                n().then(function(n) {
                    o.get(r.updateUserInfo + "&loginToken=" + n, i).then(function(n) {});
                });
            }
        });
    }
};